package cn.chenwx.entity;

import lombok.Data;
import org.springframework.stereotype.Component;

import java.util.HashMap;

/**
 * Created with IntelliJ IDEA
 */

@Data
public class ResultMap {


    private Integer status;
    private String msg;
    private Object data;


    public ResultMap(Object data) {
        this.status = 200;
        this.msg = "OK";
        this.data = data;
    }
    public ResultMap(Integer status, String msg, Object data) {
        this.status = status;
        this.msg = msg;
        this.data = data;
    }

    public static ResultMap build(Integer status, String msg, Object data) {
        return new ResultMap(status, msg, data);
    }


    public static ResultMap ok(Object data) {
        return new ResultMap(data);
    }


    public static ResultMap ok() {
        return new ResultMap(null);
    }

    public static ResultMap errorMsg(String msg) {
        return new ResultMap(500, msg, null);
    }

    public static ResultMap errorMap(Object data) {
        return new ResultMap(501, "error", data);
    }

    public static ResultMap errorTokenMsg(String msg) {
        return new ResultMap(502, msg, null);
    }

    public static ResultMap errorRolesMsg(String msg) {
        return new ResultMap(503, msg, null);
    }

    public static ResultMap errorException(String msg) {
        return new ResultMap(555, msg, null);
    }




}

